package com.alcargo.tools.sample.main;


import java.io.UnsupportedEncodingException;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Log4jSampleMain {

	/**
	 * @param args
	 */
	/**
	 * @param args
	 * @throws UnsupportedEncodingException 
	 */
	public static void main(String[] args) throws UnsupportedEncodingException {
		Log4jSampleMain m = new Log4jSampleMain();
		m.localPath();
		
	}

	public String localPath() throws UnsupportedEncodingException{
		System.out.println("this is log4j test");		
		Logger logger = Logger.getLogger(Log4jSampleMain.class );
		
		logger.debug("this is log4j debug ");
		String path = localPath("log4j.properties");
		PropertyConfigurator.configure(path); 
		logger.error("new properties");
		return path;
	}
	public String localPath(String srcfile){
		String path =this.getClass().getResource("/").getPath();
		path =path.replaceAll("%20"," ");// 真讨厌MS的目录格式，含有空格的要换成这样子	
		return path+srcfile;
	}
}
